package com.dm.hdfxxt.planmanage.controller;

import com.dm.hdfxxt.planmanage.service.PlanService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "goPlan")
public class PlanController {
    private static final Logger logger = LoggerFactory.getLogger(PlanController.class);

    @Autowired
    private PlanService planService;

    /**
     * @Description 保存仓库信息
     * @Author zhangxue
     * @Date 18:29 2018/9/29
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/savePlan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> savePlan(@RequestBody Map<String,Object> param){
        Map<String,Object> ResultMap = new HashMap<>();
        ResultMap = planService.savePlan(param);
        return ResultMap;
    }

    /**
     * @Description  查询所有计划
     * @Author zhangxue
     * @Date 11:35 2018/10/30
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllPlan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllPlan(@RequestBody Map<String,Object> param){
        Map<String,Object> ResultMap = planService.queryAllPlan(param);
        return ResultMap;
    }

    /**
         * @Description 删除计划
         * @Author zhangxue
         * @Date 11:57 2018/11/1
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/delPlan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> delPlan(@RequestBody Map<String,Object> param){
        Map<String,Object> ResultMap = new HashMap<>();
        ResultMap = planService.delPlan(param);
        return ResultMap;
    }

    /**
     * @Description  通过计划编号查询各店面分配数量
     * @Author zhangxue
     * @Date 11:35 2018/10/30
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryStoreNumByPlanNo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryStoreNumByPlanNo(@RequestBody Map<String,Object> param){
        Map<String,Object> ResultMap = new HashMap<>();
        List<Map<String,Object>> ResultList = planService.queryStoreNumByPlanNo(param);
        ResultMap.put("ResultList",ResultList );
        return ResultMap;
    }

}
